<?php

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
// block any attempt to the filesystem
if (isset($_GET["file"]) && basename($_GET["file"]) == $_GET["file"]) {

    $filename = $_GET["file"];
} else {

    $filename = NULL;
}

if(isset ($_GET["path"])){
    $path = $_GET["path"];
}

$err = "<p style=\"color:#990000\">Sorry, the file you are requesting is unavailable.</p>";

if (!$filename) {


    echo $err;
} else {


    $path = "." . $path . "/" . $filename;

    echo $path;
    if (file_exists($path) && is_readable($path)) {


        $size = filesize($path);
        header('Content-Type: application/octet-stream');
        header('Content-Length: ' . $size);
        header('Content-Disposition: attachment; filename=' . $filename);
        header('Content-Transfer-Encoding: binary');


        $file = @ fopen($path, "rb");

        if ($file) {

            fpassthru($file);
            exit;
        } else {

            echo $err;
        }
    } else {

        echo $err;
    }
}
?>
